<?php

Class FUserIdentity extends CBaseUserIdentity
{	
	const ERROR_FACEBOOK_INVALID = 3;
	private $facebook_id;
	private $_model;
	private $_id;
	
	public function __construct($facebook_id)
	{
		$this->facebook_id = $facebook_id;
	}
	
	public function authenticate()
	{
		$account = Account::model()->findByAttributes(array('facebook'=>$this->facebook_id));
		if($account == null){
			$this->errorCode = self::ERROR_FACEBOOK_INVALID;
		}
		else{
			$this->_model = $account;
			$this->_id = $account->uid;
			//$this->isAuthenticated = true;
			$this->errorCode = self::ERROR_NONE;
		}
		return !$this->errorCode;
	}
	
	public function getModel()
	{
		return $this->_model;
	}
	
	public function getId()
	{
		return $this->_id;
	}
}